

//infrastructure memory manager
//0.red black tree

#ifndef RBTREE_H
#define RBTREE_H

#include "stdfax.h"


#define RED (1)
#define BLACK (0)
typedef int (comprbt)(void *, void *, void *);

typedef struct _rbnode {
	struct _rbnode *parent;
	struct _rbnode *left;
	struct _rbnode *right;
	int color;
	void *key;
}rbnode;

typedef struct _rbtree {
	rbnode *root, nil;
	pthread_spinlock_t lock;
	int size;
	comprbt *c;
	void *argv;
}rbtree;


rbtree *create_rbtree(comprbt * c, void *argv);
void delete_node(rbtree *rbt, rbnode *nd);
int insert_node(rbtree *rbt, rbnode *nd);
rbnode *find_node(rbtree *rbt, void *key);
rbnode *min_node(rbtree *rbt);
int get_rbt_size(rbtree *rbt);

#endif
